﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CSharpDataAccess.Product;
using System.Data.OracleClient;
using System.Data.SqlClient;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Data;

namespace CSharpDataAccess.Factory
{
    /// <summary>
    /// By default, return a SqlServer object
    /// </summary>
    /// <remarks>Factory Method: ConcreteCreator</remarks>
    public class DataAccessHandlerFactory : IDataAccessHandlerFactory
    {
        public string StringConnection { get; set; }
        public DataProvider DataProvider { get; set; }

        public DataAccessHandlerFactory(string stringConnection)
        {
            this.StringConnection = stringConnection;            
        }

        public DataAccessHandlerFactory(string stringConnection, DataProvider provider)
            : this(stringConnection)
        {
            this.DataProvider = provider;
        }

        public  IDataAccessHandler CreateDataProvider()
        {
            switch (DataProvider)
            {
                case DataProvider.SQLServer:
                    return new SqlServer(StringConnection);
                case DataProvider.OleDb:
                    throw new NotImplementedException();
                case DataProvider.Odbc:
                    throw new NotImplementedException();
                case DataProvider.Oracle:
                    throw new NotImplementedException();
                case DataProvider.MySQL:
                    throw new NotImplementedException();
                default:
                    return new SqlServer(StringConnection);
            }
        }
    }
}